package com.ja.openchat.ui.update;

import android.content.Context;
import android.content.DialogInterface;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.ja.openchat.R;
import com.lxj.xpopup.core.CenterPopupView;

import org.jetbrains.annotations.NotNull;

public class UpdateDialog extends CenterPopupView  implements DialogInterface {

    private DialogInterface.OnClickListener onClickListener;
    private String contentStr;

    public UpdateDialog(@NonNull @NotNull Context context,String content,DialogInterface.OnClickListener listener) {
        super(context);
        this.contentStr = content;
        this.onClickListener = listener;
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.dialog_update;
    }

    @Override
    protected void initPopupContent() {
        super.initPopupContent();
        TextView content = findViewById(R.id.content);
        content.setText(contentStr);
        findViewById(R.id.update_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickListener.onClick(UpdateDialog.this,DialogInterface.BUTTON_POSITIVE);
            }
        });
        findViewById(R.id.not_hint_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickListener.onClick(UpdateDialog.this,DialogInterface.BUTTON_NEUTRAL);
            }
        });
        findViewById(R.id.cancle_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickListener.onClick(UpdateDialog.this,DialogInterface.BUTTON_NEGATIVE);
            }
        });
    }

    @Override
    public void cancel() {

    }
}
